<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: pink;
            left: 10px;
            position: absolute;
            top: 20px;
        }
    </style>
</head>
<body>
<div id="box" style="left:30px;width: 100px;height: 100px;"></div>
</body>
</html>
<script>
    var box =document.getElementById("box");
    console.log(box.style.left);
    console.log(box.style["left"]);
    function fn(attr){
        console.log(box.style[attr]);
    }
    fn("height");
    fn("width");
</script>